home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Developer Toolbox 6.1
/
SGI Developer Toolbox 6.1 - Disc 4.iso
/
src
/
haeberli
/
tools
/
palette.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-01
|
2KB
|
84 lines
/*
* Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
/*
* palette -
* Display a pallete of colors. A new palette may be selected
* by pointing with the mouse and clicking the left mouse button.
*
* Paul Haeberli - 1984
*
*/
#include "gl.h"
#include "device.h"
#include "port.h"
#include "stdio.h"
int c1, c2;
main(argc,argv)
int argc;
char **argv;
{
short dev, val;
int one, two;
c1 = 0;
c2 = c1+255;
winopen("palette");
glcompat(GLC_SOFTATTACH,TRUE);
qdevice(LEFTMOUSE);
qdevice(ESCKEY);
drawit();
while (1) {
switch(qread(&val)) {
case REDRAW:
reshapeviewport();
drawit();
break;
case LEFTMOUSE:
if (!val) {
c1 = c2;
c2 = getapixel(getvaluator(MOUSEX),getvaluator(MOUSEY));
}
drawit();
break;
case ESCKEY:
exit(0);
break;
}
}
}
drawit()
{
register int i;
if (c1<c2) {
ortho2((float)c1,(float)c2+1,0.0,1.0);
for (i=c1; i<=c2; i++) {
color(i);
rectfi(i,0,i+1,1);
}
} else {
ortho2((float)c1+1,(float)c2,0.0,1.0);
for (i=c2; i<=c1; i++) {
color(i);
rectfi(i,0,i+1,1);
}
}
}